import sys
import os
from pathlib import Path
from PyQt6.QtWidgets import QApplication
from PyQt6.QtCore import QSettings,QUrl
from PyQt6.QtGui import QIcon
from PyQt6.QtQml import QQmlApplicationEngine
import platform
import Bridge
def main():
    if platform.uname().system=="Windows":
        pass
    QApplication.setApplicationName("装箱单")
    QApplication.setOrganizationName("QtProject")

    app = QApplication(sys.argv)
    # QIcon.setThemeName("gallery")
    settings = QSettings()
    if not os.environ.get("QT_QUICK_CONTROLS_STYLE"):
        style_name = settings.value("style")
        if style_name:
            QQuickStyle.setStyle(style_name)
    # QQuickStyle.setStyle("Material")
    engine = QQmlApplicationEngine()
    qml_file = Path(__file__).parent / 'assets/main.qml'
    r=engine.rootContext()
    # print(dir(r))
    b=Bridge.Bridge()
    r.setContextProperty("pingPong", b);
    engine.load(str(qml_file))

    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec())
if __name__ == '__main__':
    main()
    
